﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using External.APICalling;
using BusinessRule.DTO;
using System.Configuration;
using System.Xml;
using MES.DataGateway.DBUtility;
using System.Data;
using log4net;
using System.Data.OracleClient;
using System.Text;

namespace MESWebService
{
    public class TDMSendMESDataMethod
    {        

       
        /// <summary>
        /// 更新试车任务 add YangJiang 20180703
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        public string  UpdateTestTaskData(Dictionary<string, string> para)
        {
            string strSQL = @"UPDATE mes_senddispatch_table SET STATUS=:STATUS,RESULTNOTE=:RESULTNOTE,WORKTIME=:WORKTIME,STATETIME=:STATETIME
                                WHERE TASKNO=:MESID";
            OracleParameter[] updateParam = new OracleParameter[5];
            updateParam[0] = NewParameter(":STATUS", para["STATE"], OracleType.VarChar);
            updateParam[1] = NewParameter(":RESULTNOTE", para["CONCLUSION"], OracleType.VarChar);
            updateParam[2] = NewParameter(":WORKTIME", para["WORKTIME"], OracleType.Number );
            updateParam[3] = NewParameter(":STATETIME", para["STATETIME"], OracleType.Number);
            updateParam[4] = NewParameter(":MESID", para["MESID"], OracleType.VarChar);

            int i = OracleHelper.ExecuteSql(strSQL, updateParam);
            if (i > 0)
            {
                return "";
                //return "更新记录条数:" + 1;
            }
            else
            {
                return "没有可更新记录";
            }              
        }

        /// <summary>
        /// 更新部件试验任务 add YangJiang 20180703
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        public string  UpdatePartTaskData(Dictionary<string, string> para)
        {
            string strSQL = @"UPDATE mes_senddispatch_table SET RESULTNOTE=:RESULTNOTE
                                WHERE TASKNO=:MESID";
            OracleParameter[] updateParam = new OracleParameter[2];
            updateParam[0] = NewParameter(":MESID", para["MESID"], OracleType.VarChar);
            updateParam[1] = NewParameter(":RESULTNOTE", para["CONCLUSION"], OracleType.VarChar);
            int i = OracleHelper.ExecuteSql(strSQL, updateParam);
            if (i > 0)
            {
                return "";
                //return "更新记录条数:" + 1;
            }
            else
            {
                return "没有可更新记录";
            }  
        }

        /// <summary>
        /// 新建OracleParameter参数 add YangJiang 20180703
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        public OracleParameter NewParameter(string strName,object strValue,System .Data .OracleClient .OracleType oracleType)
        {
            OracleParameter Parameter = new OracleParameter(strName, oracleType);
            Parameter.Direction = ParameterDirection.Input;
            Parameter.Value = strValue;
            return Parameter;
        }

    }
}